package com.example.john.foodstore;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;

import java.util.ArrayList;
import java.util.List;

public class OrderItemAdapter extends AppCompatActivity {
    private ListView lv;
    private String[] data=new String[]{"abc","bdc","xxer"};
    private LayoutInflater inflater;
    private ArrayList<Order> arrorder;
    private List<Order> orders=new ArrayList<Order>();

    private int[] snaps=new int[]{R.drawable.gai,R.drawable.han,R.drawable.mian};
    private OrderAdapter adapter;

    private void init(){
        for (int i=0;i<snaps.length;i++){
            Order o=new Order();
            o.setOrderName("order..."+i);
            o.setDetail("detail..." + i);
            o.setSnap(snaps[i]);
            orders.add(o);
        }
    }



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_item_adapter);
        init();
        inflater=getLayoutInflater();
        adapter=new OrderAdapter(orders,inflater);

        lv=(ListView)findViewById(R.id.lv1);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(OrderItemAdapter.this, data[position].toString(), Toast.LENGTH_LONG).show();
                Log.i("Amy", data[position]);
            }
        });

    }

    public void Unhandle(View view) {
        lv.setAdapter(adapter);
    }

    public void Dishes(View v){
        Intent intent=new Intent();
        intent.setClass(this,MyDishes.class);
        startActivityForResult(intent, 0);


    }





}
